package com.sniff.atp.service.jobs;

import com.alibaba.fastjson2.JSONObject;
import com.sniff.atp.constant.RedisPrefix;
import com.sniff.atp.dto.jobs.PowerJobDTO;
import com.sniff.atp.enums.api.PowerJobsAPI;
import com.sniff.atp.utils.HttpClientUtil;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @BelongsProject: sniff-atp
 * @BelongsPackage: com.sniff.atp.service.jobs
 * @Author: zxy
 * @CreateTime: 2024-04-03 17:14
 * @Description:
 * @Version: 1.0
 */
@Service
public class PowerJobs {

    private String com;

    public String powerJobLogin(PowerJobDTO powerJobDTO) {
        if (powerJobDTO.getEnvironment().equals("test")) {
            com = RedisPrefix.TEST_POWER_JOB;
        } else if (powerJobDTO.getEnvironment().equals("pre")) {
            com = RedisPrefix.PRE_POWER_JOB;
        }

        return new HttpClientUtil().doPostJson(com + PowerJobsAPI.LOGIN.getApi(), powerJobDTO);
    }


    public String powerJobList(Integer appId) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("appId", appId);
        jsonObject.put("index", 0);
        jsonObject.put("pageSize", 100);
        return new HttpClientUtil().doPostJson(com + PowerJobsAPI.POWERJOBS_LIST.getApi(), jsonObject);
    }


}
